import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../common/routes.dart';
import '../controller/home_controller.dart';

class HomePage extends GetView<HomeController> {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text('state_management'.tr),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            Obx(() => Text('${controller.counter}', style: const TextStyle(fontSize: 32, color: Colors.red))),
            OutlinedButton(
              child: const Text("路由管理"),
              onPressed: () {
                Get.toNamed(Routes.PROFILE);
              },
            ),
            OutlinedButton(
              child: const Text("改变语言"),
              onPressed: () {
                var locale = const Locale('en', 'US');
                Get.updateLocale(locale);
              },
            ),
            TextButton(
              child: const Text("go the first page"),
              onPressed: () {
                Get.toNamed("/first?device=phone&id=354&name=Enzo");
              },
            ),
            ElevatedButton(
                onPressed: () {
                  Get.snackbar('SnackBar', '我是SnackBar 11111111111111111111111111');
                  debugPrint("screen width=${Get.width}");
                  debugPrint("screen height=${Get.height}");
                },
                child: const Text("SnackBar")),
            TextButton(
              child: const Text("dialog"),
              onPressed: () {
                Get.defaultDialog(
                  title: "确认",
                  middleText: "你确定要继续吗？",
                  textCancel: "取消",
                  textConfirm: "确定",
                  onCancel: () {
                    debugPrint("取消");
                  },
                  onConfirm: () {
                    debugPrint("确定");
                    Get.back(); // 关闭对话框
                  },
                );
              },
            ),
            OutlinedButton(
              child: const Text("bottom sheet"),
              onPressed: () {
                Get.bottomSheet(
                    backgroundColor: Colors.white,
                    Wrap(
                      children: <Widget>[
                        ListTile(leading: const Icon(Icons.music_note), title: const Text('Music'), onTap: () {}),
                        ListTile(
                          leading: const Icon(Icons.videocam),
                          title: const Text('Video'),
                          onTap: () {},
                        ),
                      ],
                    ));
              },
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          controller.increment();
        },
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
